package org.example;

public abstract class Parser {
    protected final Lexer input; // 词法解析器
    protected Token lookahead; // 当前向前看词法单元

    public Parser(Lexer lexer) {
        input = lexer;
        consume();
    }

    public void match(int type) {
        if (lookahead.type == type) {
            consume();
        }
    }

    public void consume() {
        lookahead = input.nextToken();
    }
}
